import config from '@/config';
import RequestBase from '@/utils/request.js';

const baseRequest = new RequestBase(config.dutyUrl);

/** 获取排班日历 */
export function getCalendar(data) {
	return baseRequest.get('/dtr/mobile/Shifting/getCalendar', data);
}

/** 新增交接班信息 */
export function addChangeShift(data) {
	return baseRequest.post('/dtr/changeShift/addChangeShift', data);
}

/** 交班记录列表 */
export function getRecordList(data) {
	return baseRequest.get('/dtr/changeShift/list', data);
}

/** 查询交接班详情信息 */
export function getShiftingInfo(id) {
	return baseRequest.get('/dtr/mobile/Shifting/info/' + id);
}

/** 接班班长确认 */
export function takeoverMonitorConfirm(data) {
	return baseRequest.post('/dtr/changeShift/takeoverMonitorConfirm', data);
}

/** 流程处理 */
export function process(data) {
	return baseRequest.post('/dtr/changeShift/process', data);
}

/** 查询可回退节点列表 */
export function getRollbackNodes(taskId) {
	return baseRequest.get('/dtr/common/getRollbackNodes/' + taskId);
}

/** 获取交接班信息详情 */
export function getMonitorUpdateInfo(changeShiftInfoId) {
	return baseRequest.get(
		'/dtr/changeShift/monitorUpdateInfo/' + changeShiftInfoId
	);
}

// 交班班长处理
export function handoverMonitorConfirm(data) {
	return baseRequest.post('/dtr/changeShift/handoverMonitorConfirm/', data);
}

// 查询交接班详情信息
export function getChangeShiftInfo(id) {
	return baseRequest.get('/dtr/changeShift/info/' + id);
}

// 获取当前班组巡检内容
export function getChangeShiftPollingList(classId, teamDate, handoverDeptId) {
	return baseRequest.get(
		`/dtr/changeShift/polling-list?classId=${classId}&teamDate=${teamDate}&handoverDeptId=${handoverDeptId}`
	);
}

// 获取当前班组隐患内容
export function getChangeShiftHiddenDangerList(handoverDeptId) {
	return baseRequest.get(
		`/dtr/changeShift/hidden-danger-list?handoverDeptId=${handoverDeptId}`
	);
}

// 获取检修作业
export function getChangeOverhaulList(handoverDeptId) {
	return baseRequest.get(
		`/dtr/changeShift/over-haul-List?handoverDeptId=${handoverDeptId}`
	);
}

// 当班主操处理
export function mainOperation(data) {
	return baseRequest.post('/dtr/changeShift/main-operation', data);
}

// 接班确认
export function takeoverConfirm(data) {
	return baseRequest.post('/dtr/mobile/Shifting/takeover-confirm', data);
}

// 当班巡检签字
export function pollingConfirm(data) {
	return baseRequest.post('/dtr/mobile/Shifting/polling-confirm', data);
}

// 班次
export function getBanCi(itemId) {
	return baseRequest.get(`/dtr/mobile/Shifting/getItemClassList/${itemId}`);
}

// 对应班次的排班对象
export function getShiftObject(data) {
	return baseRequest.get(`/dtr/range-class/schedule/scheduleObjectList`, data);
}

// 排版日历
export function getShiftCalendar(data) {
	return baseRequest.get('/dtr/mobile/Shifting/getCalendar', data);
}

// 根据排班日期 人员获取排班列表
export function getScheduleItemList(data) {
	return baseRequest.post(
		'/dtr/range-class/schedule/getScheduleItemList',
		data
	);
}

// 根据排班日期 班次 排班事项获取人员 （已废弃，现使用班前会接口duty-meeting.js -> getDutyUser）
export function getScheduleDutyUserList(data) {
	return baseRequest.post(
		`/dtr/range-class/schedule/getScheduleDutyUserList`,
		data
	);
}

// 根据事项id获取班次
export function getClassList(itemId, teamDate) {
	return baseRequest.get(
		`/dtr/range-class/schedule/getCurrentClassList?itemId=${itemId}&handoverTime=${teamDate}`
	);
}

// 获取下一个班次
export function getNextClass(classId, itemId, teamDate) {
	return baseRequest.get(
		`/dtr/range-class/schedule/getNextClassList?classId=${classId}&itemId=${itemId}&teamDate=${teamDate}`
	);
}

// 根据班次获取接班班组
export function getTakeoverDept(classId, itemId, teamDate) {
	return baseRequest.get(
		`/dtr/changeShift/getTakeoverDept?classId=${classId}&itemId=${itemId}&teamDate=${teamDate}`
	);
}

// 获取接班班长
export function getTakeOverUser(classId, deptId, itemId, teamDate) {
	return baseRequest.get(
		`/dtr/changeShift/getTakeOverUser?classId=${classId}&deptId=${deptId}&itemId=${itemId}&teamDate=${teamDate}`
	);
}

// 获取已存在的交班班次
export function getScheduledClass(teamDate, itemId) {
	return baseRequest.get(
		`/dtr/changeShift/getExistHandoverClassIdList?teamDate=${teamDate}&itemId=${itemId}`
	);
}

// 获取分厂id
export function getHandoverDept(classId, teamDate) {
	return baseRequest.get(
		`/dtr/changeShift/getHandoverDept?classId=${classId}&teamDate=${teamDate}`
	);
}